#include "GarbageCollectable.h"

#include "Type.h"
#include "PropertyList.h"
#include "Property.h"
#include "PropertyFieldInterface.h"

void CPropertyGarbageCollectable::CollectReferencedObjects(void * InInstance, TForwardForwardLinkedList<RObject*>& OutReferencedObjects)
{
    if(Type->Properties==nullptr)
    {
        return;
    }

    for(auto& Field : Type->Properties->GetNonStaticFieldProperties())
    {
        auto FieldType = Field->GetType().BasicType;
        if(FieldType->GarbageCollectable)
        {
            void* FieldValue= Field->FieldProperty->GetValuePointer(InInstance);
            FieldType->GarbageCollectable->CollectReferencedObjects(FieldValue, OutReferencedObjects);
        }
    }        
}